package net.zjitc.pojo.api;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

//通用响应--分页
@EqualsAndHashCode(callSuper = true)
//@AllArgsConstructor
@NoArgsConstructor
@Data
public class PageResult<T> extends Result<T> {

    private Integer total;

    public PageResult(Integer code) {
        super(code, "查询成功");
    }

    public PageResult( String msg, T data, Integer total) {
        this.setData(data);
        this.total = total;
    }

    public static <T> Result<T> success(T data, Integer total) {
        PageResult<T> result = new PageResult<>(ResultCode.REQUEST_SUCCESS.getCode());
        result.setData(data);
        result.setTotal(total);
        return result;
    }

}
